var thisadre;
var currentEngineCriteriaPage=1;
var currentDriviterianCriteriaPage=1;
var currentTransmissionCriteriaPage=1;
var currentWantCriteriaPage=1;
var currentContactCriteriaPage=1;
var currentPaperCriteriaPage=1;
var currentLocatedCriteriaPage=1;
var currentDeliverCriteriaPage=1;
var currentAdsourceCriteriaPage=1;

var startEngineCriteria=0;
var startDriCriteria=0;
var startTranCriteria=0;
var startWantCriteria=0;
var startContactCriteria=0;
var startPaperCriteria=0;
var startLocatedCriteria=0;
var startDeliverCriteria=0;
var startAdsourceCriteria=0;

var countEngineCriteria=4;
var countDriCriteria=4;
var countTranCriteria=4;
var countWantCriteria=4;
var countContactCriteria=4;
var countPaperCriteria=4;
var countLocatedCriteria=4;
var countDeliverCriteria=4;
var countAdsourceCriteria=4;

var AddresourceProxy = Objs("model.AddresourceProxy",
	Proxy,
{
	initialize: function( name,lists)
	{ 
		AddresourceProxy.$super.initialize.call( this, name,lists);
		thisadre=this;
	},	
	load:function()
	{
		$.ajax({
				type: "POST",
				url:"../services/AssetService.php?action=getallassets",
				success: function(data,status) {
				var assetsdata= eval('(' + data + ')');
				thisadre.sendNotification( NotificationNames.ASSETDATA, assetsdata );	
				//	$("#datacontent").show();
		
				//	$("#progress").hide();
				},
				error:function(error,response){
				}
			});
	},
	loadEngineCriterias:function()
	{
		var pagelimit=new Object();
		pagelimit.start=startEngineCriteria;
		pagelimit.count=countEngineCriteria;
		$.ajax({
				type: "POST",
				url:"../services/AssetService.php?action=getenginecriterias",
				data:pagelimit,
				success: function(data,status) {
				var assetsdata= eval('(' + data + ')');
				thisadre.sendNotification( NotificationNames.ENGINE, assetsdata );	
				//	$("#datacontent").show();
		
				//	$("#progress").hide();
				},
				error:function(error,response){
				}
			});
	},
	loadDriCriterias:function()
	{
		var pagelimit=new Object();
		pagelimit.start=startDriCriteria;
		pagelimit.count=countDriCriteria;
		$.ajax({
				type: "POST",
				url:"../services/AssetService.php?action=getdricriterias",
				data:pagelimit,
				success: function(data,status) {
				var assetsdata= eval('(' + data + ')');
			
				thisadre.sendNotification(NotificationNames.DRI, assetsdata );	
				//	$("#datacontent").show();
		
				//	$("#progress").hide();
				},
				error:function(error,response){
				}
			});
	},
	loadTranCriterias:function()
	{
		var pagelimit=new Object();
		pagelimit.start=startTranCriteria;
		pagelimit.count=countTranCriteria;
		$.ajax({
				type: "POST",
				url:"../services/AssetService.php?action=getdtrancriterias",
				data:pagelimit,
				success: function(data,status) {
				var assetsdata= eval('(' + data + ')');
				thisadre.sendNotification( NotificationNames.TRAN, assetsdata );	
				//	$("#datacontent").show();
		
				//	$("#progress").hide();
				},
				error:function(error,response){
				}
			});
	},
	loadWantCriterias:function()
	{
		var pagelimit=new Object();
		pagelimit.start=startWantCriteria;
		pagelimit.count=countWantCriteria;
		$.ajax({
				type: "POST",
				url:"../services/AssetService.php?action=getwantcriterias",
				data:pagelimit,
				success: function(data,status) {
				var assetsdata= eval('(' + data + ')');
				thisadre.sendNotification( NotificationNames.WANT, assetsdata );	
				//	$("#datacontent").show();
		
				//	$("#progress").hide();
				},
				error:function(error,response){
				}
			});
	},
	loadContactCriterias:function()
	{
		var pagelimit=new Object();
		pagelimit.start=startContactCriteria;
		pagelimit.count=countContactCriteria;
		$.ajax({
				type: "POST",
				url:"../services/AssetService.php?action=getcontactcriterias",
				data:pagelimit,
				success: function(data,status) {
				var assetsdata= eval('(' + data + ')');
				thisadre.sendNotification( NotificationNames.CONTACT, assetsdata );	
				//	$("#datacontent").show();
		
				//	$("#progress").hide();
				},
				error:function(error,response){
				}
			});
	},
	loadPaperCriterias:function()
	{ 
		var pagelimit=new Object();
		pagelimit.start=startPaperCriteria;
		pagelimit.count=countPaperCriteria;
		$.ajax({
				type: "POST",
				url:"../services/AssetService.php?action=getpapercriterias",
				data:pagelimit,
				success: function(data,status) {
				var assetsdata= eval('(' + data + ')');
				
				thisadre.sendNotification( NotificationNames.PAPERWORK, assetsdata );	
				//	$("#datacontent").show();
		
				//	$("#progress").hide();
				},
				error:function(error,response){
				}
			});
	},
	loadLocatedCriterias:function()
	{ 
		var pagelimit=new Object();
		pagelimit.start=startLocatedCriteria;
		pagelimit.count=countLocatedCriteria;
		$.ajax({
				type: "POST",
				url:"../services/AssetService.php?action=getlocatedcriterias",
				data:pagelimit,
				success: function(data,status) {
				var assetsdata= eval('(' + data + ')');
				
				thisadre.sendNotification( NotificationNames.LOCATED, assetsdata );	
				//	$("#datacontent").show();
		
				//	$("#progress").hide();
				},
				error:function(error,response){
				}
			});
	},
	loadDeliverCriterias:function()
	{ 
		var pagelimit=new Object();
		pagelimit.start=startDeliverCriteria;
		pagelimit.count=countDeliverCriteria;
		$.ajax({
				type: "POST",
				url:"../services/AssetService.php?action=getdelivercriterias",
				data:pagelimit,
				success: function(data,status) {
				var assetsdata= eval('(' + data + ')');
				
				thisadre.sendNotification( NotificationNames.DELIVER, assetsdata );	
				//	$("#datacontent").show();
		
				//	$("#progress").hide();
				},
				error:function(error,response){
				}
			});
	},
	loadAdsourceCriterias:function()
	{ 
		var pagelimit=new Object();
		pagelimit.start=startAdsourceCriteria;
		pagelimit.count=countAdsourceCriteria;
		$.ajax({
				type: "POST",
				url:"../services/AssetService.php?action=getadsourcecriterias",
				data:pagelimit,
				success: function(data,status) {
				var assetsdata= eval('(' + data + ')');
				
				thisadre.sendNotification( NotificationNames.ADSOURCE, assetsdata );	
				//	$("#datacontent").show();
		
				//	$("#progress").hide();
				},
				error:function(error,response){
				}
			});
	},
	addItem:function()
	{
	  var itemcontent=new Object();
	  itemcontent.created_by=global_user.admin_id;
	  itemcontent.asset_datafield='';
	  itemcontent.asset_category=item_id;
	  itemcontent.asset_name=$("#txtaddItem").val();
	  $.ajax({
				type: "POST",
				url:"../services/AssetService.php?action=addAsset",
				data:itemcontent,
				success: function(data,status) {
			
				thisadre.sendNotification( NotificationNames.ADDITEM, 'success' );	
				$("#txtaddItem").val('');
				$('#addItemPopup').modal('hide');
				bootbox.alert("Item Saved Successfully");
				//	$("#datacontent").show();
		
				//	$("#progress").hide();
				},
				error:function(error,response){
				}
			});
	},
	editItem:function()
	{
	  var itemcontent=new Object();
	  itemcontent.updated_by=global_user.admin_id;
	  itemcontent.asset_datafield='';
	  itemcontent.asset_id=$("#editItemPopup").data("itemID");;
	  itemcontent.asset_name=$("#txteditItem").val();
	  $.ajax({
				type: "POST",
				url:"../services/AssetService.php?action=editAsset",
				data:itemcontent,
				success: function(data,status) {
			
				thisadre.sendNotification( NotificationNames.ADDITEM, 'success' );	
				$("#txteditItem").val('');
				$('#editItemPopup').modal('hide');
				bootbox.alert("Item Updated Successfully");
				//	$("#datacontent").show();
		
				//	$("#progress").hide();
				},
				error:function(error,response){
				}
			});
	},
	deleteItem:function(asset_id)
	{
	  var itemcontent=new Object();
	  itemcontent.asset_id=asset_id;
	  $.ajax({
				type: "POST",
				url:"../services/AssetService.php?action=deleteAsset",
				data:itemcontent,
				success: function(data,status) {
			
				thisadre.sendNotification( NotificationNames.ADDITEM, 'success' );	
				
				bootbox.alert("Item Deleted Successfully");
				//	$("#datacontent").show();
		
				//	$("#progress").hide();
				},
				error:function(error,response){
				}
			});
	}
});
 